//
//  LocationConfigMananger.m
//  高仿暴走斗图
//
//  Created by key on 16/3/28.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "LocationConfigMananger.h"

static LocationConfigMananger *locationConfigManager;

@implementation LocationConfigMananger

+ (instancetype)shareInstance {
    
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        locationConfigManager = [[LocationConfigMananger alloc] init];
    });
    return locationConfigManager;
}


- (instancetype)init {
    
    if (self = [super init]) {
        
    }
    return self;
}


#pragma mark - Create Data Plist

- (void)createConfigDataPlist {
    
    NSString *path = [self createDocumentConfigFileManager];
    NSDictionary *data = @{
                           BASE_URL : BASE_URL,
                           };
    NSString *plistPath = [path stringByAppendingString:@"Data.plist"];
    [data writeToFile:plistPath atomically:YES];
}

#pragma mark - Create File Path

- (NSString *)createDocumentConfigFileManager {
    
    NSFileManager *fileManager = [NSFileManager defaultManager];
    NSString *pathDocuments = kPATH_DOCUMENT;
    NSString *createPath = [NSString stringWithFormat:@"%@/%@", pathDocuments, PATHDOCUMENT_CONFIG_FILE_PATH];
    
    BOOL isCreatePath = [LocationConfigMananger checkFileWithPath:createPath];
    // 判断文件夹是否存在，如果不存在，则创建
    if (!isCreatePath) {
        [fileManager createDirectoryAtPath:createPath withIntermediateDirectories:YES attributes:nil error:nil];
    }
    return createPath;
}

+ (BOOL)checkFileWithPath:(NSString *)path {
    
    NSFileManager *manager = [NSFileManager defaultManager];
    BOOL tag = [manager fileExistsAtPath:path isDirectory:NULL];
    return tag;
}


@end
